<?php
// $Id: taxonomy.pages.inc,v 1.9.2.1 2009/04/27 11:49:05 goba Exp $

/**
 * @file
 * Page callbacks for the taxonomy module.
 */

/**
 * Menu callback; displays all nodes associated with a term.
 */

/*function taxonomy_custom_sublist($str_tids = '', $depth = 0, $op = 'page') 
{
 $terms = taxonomy_terms_parse_string($str_tids);
  if ($terms['operator'] != 'and' && $terms['operator'] != 'or') {
    drupal_not_found();
  }
	
 $query3 = "SELECT term_data.name AS name,term_data.description AS description,term_data.tid AS tid,
   term_data.vid AS vid,term_hierarchy.parent as parent 
 FROM term_data term_data 
 LEFT JOIN term_hierarchy term_hierarchy ON term_data.tid = term_hierarchy.tid
 WHERE parent='".arg(2)."'";
$result3 = db_query($query3);

while($data3 = db_fetch_object($result3))
{
 $quesid=$data3->tid;
$second.="<li>";
$second.="<a href='http://www.smsvidya.com/tests/lists/sublists/".$data3->tid."'>".$data3->name."</a><br>";
$second.=$data3->description;
$second.="</li>";
$second.="<hr>";


}


return $second;



}*/

function taxonomy_custom_thirdsublist($str_tids = '', $depth = 0, $op = 'page'){
	global $base_url;
	drupal_add_js(drupal_get_path('module', 'taxonomy_custom').'/ajax-view.js');

$terms = taxonomy_terms_parse_string($str_tids);
  if ($terms['operator'] != 'and' && $terms['operator'] != 'or') {
    drupal_not_found();
  }	


/* $query4="SELECT node.title AS title, node.nid AS nid, node.uid AS uid, node.vid AS vid, node_data_field_related_product.field_related_product_nid AS node_data_field_related_product_field_related_product_nid, node_data_field_related_product.field_product_description_value AS related_product_description, node.type AS node_type, node.vid AS node_vid, node.title AS node_title
FROM node node
LEFT JOIN term_node term_node_value_0 ON node.vid = term_node_value_0.vid
AND term_node_value_0.tid = '".arg(2)."'
LEFT JOIN content_type_quiz node_data_field_related_product ON node.vid = node_data_field_related_product.vid
WHERE term_node_value_0.tid = '".arg(2)."'
AND node_data_field_related_product.field_related_product_nid = '".arg(3)."'";*/
$query4="SELECT quiz.field_related_product_nid,node.title,node.nid,node.vid,node.uid from {content_type_quiz} as quiz ,{node} as node where quiz.field_related_product_nid='".arg(3)."' and node.nid=quiz.nid group by node.nid";
$result4 = db_query($query4);
$ajaxurl = $base_url."/tests/queslist/".arg(2);  

/*$third.="<div class='select_que'><select name='search' id='search'  style='width:100%;' onchange='loadPage(\"".$ajaxurl."\",".arg(3).")'>";*/
$third.="<div class='select_que'><select name='search' id='search'  style='width:100%;' >";

$nodes_list = get_node_from_term_id(arg(2));

          for($i=0;$i<count($nodes_list['title']);$i++)
	  {
			  		 $product = node_load($nodes_list['product_id'][$i]);
if(arg(3) == $nodes_list['product_id'][$i])
{
$selected = 'selected="selected"';
}
else{
$selected="";
}

        $third .= "<option value='".$nodes_list['product_id'][$i]."' ".$selected.">".$product->title."</option>";
                        	
          }
                    
                                  
 $third.="</select></div><div id='queslist'>
 <table cellpadding='2' cellspacing='1' class='marketing_table'>
                    	<tr>
                        	<th>Test Name</th>
                            <th>Creator</th>
                            <th>Responses</th>
                            <th>Rating</th>
                        </tr>";
while($data4 = db_fetch_object($result4))
{
	$node = node_load($data4->nid);	
$query5 = "SELECT * FROM users WHERE uid='".$data4->uid."'";
$result5 = db_query($query5);
$data5 = db_fetch_object($result5);
$result6= db_query("SELECT (count(*)+100) as count from quiz_node_results where nid=".$data4->nid." and vid=".$data4->vid);
$data6 = db_fetch_object($result6);


	$quiz_title = $base_url.'/node/'.$data4->nid.'/take';
$third.="<tr><td width='160'><a title='".$data4->title."' href='".$quiz_title."'>".substr($data4->title,0,17)."..."."</a></td>
                            <td><span title='".$node->field_created_by[0]['value']."'>".substr($node->field_created_by[0]['value'],0,17)."..."."</span></td>
                            <td>".$data6->count."</td>
                            <td width='55'>";?>
                            <?php
							
                            if (function_exists('fivestar_widget_form')) $third.= fivestar_static('node', $node, NULL, 'quiz');
							
							?>
                            
                            <?php $third.="</td></tr>";
  


}
$third.="</table></div>";
return $third;
		

} 




